<?php
namespace app\api\controller\xiservice;

use app\common\controller\xiservice\XiserviceApi;
use app\common\model\xiservice\Benfit as BenfitModel;
use app\common\model\xiservice\Service;
use think\Db;
/**
 * 收益模块
 */
class Benfit extends XiserviceApi
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];



    /**
     * @ApiTitle (服务人员收益明细)
     * @ApiMethod (GET)
     * @ApiRoute (/api/xiservice.benfit/list)
     * @ApiHeaders (name=token, type=string, description="Token")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturnParams   (name="data", type="object", sample="{'id':'int','order':'object','money':'float','createtime':'int','createtime_text':'date'}", description="返回数据")
     */
    public function list() {
        $res = Db::name('xiservice_user')->where('user_id',$this->auth->id)->find();
        // echo "<pre>";
        // print_r($res['id']);die;
        $list = BenfitModel::with(['order'=>function($query){
                        $query->withField('order_no');
                 }])
                ->where('benfit.user_id',$res['id'])
                ->where('type',1)
                ->order('createtime desc')
                ->paginate();
        $this->success('查询成功',$list);
    }


}